//
//  ChargeWithdrawTipsView.swift
//  baihuiju
//
//  Created by 赵家彬 on 2018/6/23.
//  Copyright © 2018年 赵家彬. All rights reserved.
//

import UIKit

class ChargeWithdrawTipsView: UIView {

    @IBOutlet weak var ivResult: UIImageView!
    
    @IBOutlet weak var lblTitle: UILabel!
    
    @IBOutlet weak var lblInfo: UILabel!
    
    
    
    //展示
    var vwContent:UIView?
    func show(isSuccess:Bool, type:Int, tipsFailInfo:String) {
        
        ivResult.image = UIImage(named: isSuccess ? "ok" : "no")
        let strType = (type == 0) ? "充值" : "提现"
        let strResult = isSuccess ? "完成！" : "失败！"
        lblTitle.text = strType + strResult
        
        var strTips = "请等待我们的人工审核"
        if isSuccess == false {
            if tipsFailInfo.isEmpty {
                strTips = "操作失败，发生异常"
            } else {
                strTips = tipsFailInfo
            }
        }
        lblInfo.text = strTips
        
        if let delegate = UIApplication.shared.delegate as? AppDelegate {
            vwContent = UIView(frame: CGRect(x: 0, y: 0, width: S_Width, height: S_Height))
            vwContent?.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.6)
            delegate.window?.addSubview(vwContent!)
            
            vwContent?.addSubview(self)
            self.snp.makeConstraints { (make) in
                make.width.equalTo(270)
                make.height.equalTo(219)
                make.center.equalToSuperview()
            }
        }
    }
    
    @IBAction func closeAction(_ sender: UIButton) {
        
        self.removeFromSuperview()
        vwContent?.removeFromSuperview()
        vwContent = nil
        
    }
    
    
    override func awakeFromNib() {
        super.awakeFromNib()
    }

}
